package com.tt.fashionWebSite.controller;

import com.tt.fashionWebSite.dto.*;
import com.tt.fashionWebSite.service.Ad_RuleService;
import com.tt.fashionWebSite.service.ConsultantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;

/**
 * Created by isoft-work 5 on 1/11/2015.
 */
@Controller
public class Ad_RuleController {
   @Autowired
   private Ad_RuleService ad_ruleService;

   @RequestMapping(value = "/admin/consultant/getRule/", method = RequestMethod.POST)
   public @ResponseBody
   JsonResponseDto<List<RuleOutputDto>> getRule(HttpServletRequest request, @RequestBody RuleInputDto ruleInputDto) throws ParseException {
      return new JsonResponseDto<List<RuleOutputDto>>(ad_ruleService.getRule(ruleInputDto), JsonResponseCode.SUCCESS);
   }

   @RequestMapping(value = "/admin/consultant/updateRule/", method = RequestMethod.POST)
   public @ResponseBody
   JsonResponseDto<Integer> updateRule(HttpServletRequest request, @RequestBody List<RuleOutputDto> ruleOutputDto) throws ParseException {
      return new JsonResponseDto<Integer>(ad_ruleService.updateRule(ruleOutputDto));
   }

   @RequestMapping(value = "/admin/consultant/getRuleOut/", method = RequestMethod.GET)
   public @ResponseBody
   JsonResponseDto<List<TapLuatKetHopDto>> updateRule(HttpServletRequest request) throws ParseException {
      return new JsonResponseDto<List<TapLuatKetHopDto>>(ad_ruleService.getRuleOut(), JsonResponseCode.SUCCESS);
   }
}
